const { app, BrowserWindow } = require("electron");
const path = require("path");

const createWindow = () => {
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
  });

  // 使用 loadFile 加载 electron/index.html 文件
    mainWindow.loadFile(path.join(__dirname, "../dist/index.html"));
//   mainWindow.loadURL("http://localhost:8000/");
};

// 在应用准备就绪时调用函数
app.whenReady().then(() => {
  createWindow();
});

const mqtt = require("mqtt");

// const client = mqtt.connect("mqtt://47.97.125.245:1883", {
//   clientId: "asdasd",
//   username: "admin",
//   password: "public",
// });

// client.on("connect", () => {
//   console.log("mqtt connect success");
//   client.subscribe("xzrobot/#", function (err) {
//     if (!err) {
//       console.log("subscribe success");
//     }
//   });
// });

// client.on("message", (topic, message) => {
//   console.log(`${message.toString()}\nOn topic: ${topic}`);
// });
